/*
 * PriorBI co., ltd.
 * CopyRight 2009-2010
 */
package com.reportgear.report.model.script;

import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;

/**
 * 表达式计算
 * 
 * @author lexloo
 * @version 1.0 Jan/15/2010
 */
public class Expression {
	public Expression() {
	}

	public Object eval(String expression) {
		try {
			ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expression));
			CommonTokenStream tokens = new CommonTokenStream(lexer);
			ExprParser parser = new ExprParser(tokens);
			return parser.expr();
		} catch (Exception ex) {
			return "";
		}
	}
}
